#!/bin/bash

PERFMON_ARGS=

while [ "$1" != "" ]; do
	case $1 in
		--* )
			PERFMON_ARGS="$PERFMON_ARGS $1 "
			;;	
		* )
			PERFMON_ARGS="$PERFMON_ARGS \"$1\" "
			;;
	esac
	shift
done

if [ x"" = x"$GPPERFMONHOME" ]; then
	echo "Error: GPPERFMONHOME environment variable not set"
	echo "Please source the gpperfmon_path.sh file"
	exit 1
fi

export PYTHONPATH=$GPPERFMONHOME/lib/python
export PYTHONHOME=$GPPERFMONHOME/ext/python
export PATH=$GPPERFMONHOME/ext/python/bin:$PATH

if [ xDarwin = x`uname -s` ]; then
	export DYLD_LIBRARY_PATH=${GPPERFMONHOME}/lib:${GPPERFMONHOME}/ext/python/lib:${DYLD_LIBRARY_PATH}
#	export DYLD_LIBRARY_PATH
else
	export LD_LIBRARY_PATH=${GPPERFMONHOME}/lib:${GPPERFMONHOME}/ext/python/lib:${LD_LIBRARY_PATH}
#	export LD_LIBRARY_PATH
fi

if [ "$1" != "-q" ]; then
	type python >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo "Warning: Python not found.  Python-2.5.1 or better is required to run gpload."
	fi
fi

eval $GPPERFMONHOME/bin/gpperfmon.py $PERFMON_ARGS
